<script lang="ts" setup>
import { ref } from "vue"
// 这不是响应式数据
const tabMetas = [
  { title: "密码登录", subTitle: "验证码登录" },
  { title: "验证码登录", subTitle: "密码登录" },
]

const current = ref(0)
</script>

<template>
  <!-- 建议  view代替 -->
  <!-- <div class="user-login"></div> -->

  <view class="user-login">
    <!-- 开启flex后 子结构就会一行布局 -->
    <view class="login-type">
      <view class="title">{{ tabMetas[current].title }}</view>
      <view class="type" @click="current = current == 0 ? 1 : 0">
        <text>{{ tabMetas[current].subTitle }}</text>
        <!-- 图标   自己的图标 iconfont   xxx            官方图标 -->
        <uni-icons type="right" color="3c3e42"></uni-icons>
      </view>
    </view>
  </view>

  <view class="form">
    <custom-mobile v-if="current == 0"></custom-mobile>
    <custom-password v-else></custom-password>
  </view>

  <view class="social-login">
    <view class="legend">
      <text class="text">三方登录</text>
    </view>
    <view class="social-account">
      <view class="icon">
        <uni-icons type="weixin" color="#07c160" size="30" />
      </view>
      <view class="icon">
        <uni-icons type="qq" color="#00b0fb" size="30" />
      </view>
      <view class="icon">
        <uni-icons type="weibo" color="#fb6622" size="30" />
      </view>
    </view>
  </view>
</template>

<style scoped lang="scss">
.form {
  padding: 30rpx;
}

.user-login {
  padding: 60rpx;

  .login-type {
    display: flex;
    // 主轴
    justify-content: space-between;
    // 侧轴
    align-items: end;

    .title {
      // 设计稿量了24
      font-size: 48rpx;
      color: #121826;
    }

    .type {
      color: #3c3e42;
      font-size: 30rpx;
    }
  }
}

.social-login {
  padding: 0 60rpx;
  margin: 100rpx 0;

  .legend {
    height: 40rpx;
    border-top: 1px solid #000;
    // 相对定位 => 子绝父相(基于老父亲定位)
    position: relative;

    .text {
      background-color: #fff;
      padding: 0 30rpx;
      // 绝对定位
      position: absolute;

      left: 50%; // 移动到老爹的一半
      transform: translate(-50%, -50%); // 左挪动自己的一半
      // top: 50%;
    }
  }

  .social-account {
    display: flex;
    justify-content: center;

    .icon {
      width: 80rpx;
      height: 80rpx;

      display: flex;
      justify-content: center;
      align-items: center;
    }
  }
}
</style>
